<?php

/**
 * This is the model class for table "ecom_transaction_detail".
 *
 * The followings are the available columns in table 'ecom_transaction_detail':
 * @property string $transaction_detail_id
 * @property string $transaction_detail_transaction_id
 * @property string $transaction_detail_products_id
 * @property string $transaction_detail_products_code
 * @property string $transaction_detail_products_name
 * @property string $transaction_detail_quantity
 * @property string $transaction_detail_price
 */
class ecom_transaction_detail extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return ecom_transaction_detail the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'ecom_transaction_detail';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('transaction_detail_transaction_id', 'length', 'max' => 20),
            array('transaction_detail_products_id, transaction_detail_quantity, transaction_detail_price,transaction_detail_bv', 'length', 'max' => 10),
            array('transaction_detail_products_code', 'length', 'max' => 25),
            array('transaction_detail_products_name', 'length', 'max' => 100),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('transaction_detail_id, transaction_detail_transaction_id, transaction_detail_products_id, transaction_detail_products_code, transaction_detail_products_name, transaction_detail_quantity, transaction_detail_price,transaction_detail_bv', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_transaction_detail_to_transaction' => array(self::BELONGS_TO, 'ecom_transaction', 'transaction_id'),
            'rel_transaction_detail_to_products' => array(self::HAS_MANY, 'ecom_products', 'products_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'transaction_detail_id' => 'Transaction Detail',
            'transaction_detail_transaction_id' => 'Transaction Detail',
            'transaction_detail_products_id' => 'Products',
            'transaction_detail_products_code' => 'Products Code',
            'transaction_detail_products_name' => 'Products Name',
            'transaction_detail_quantity' => 'Quantity',
            'transaction_detail_price' => 'Price',
            'transaction_detail_bv' => 'BV',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('transaction_detail_id', $this->transaction_detail_id, true);
        $criteria->compare('transaction_detail_transaction_id', $this->transaction_detail_transaction_id, true);
        $criteria->compare('transaction_detail_products_id', $this->transaction_detail_products_id, true);
        $criteria->compare('transaction_detail_products_code', $this->transaction_detail_products_code, true);
        $criteria->compare('transaction_detail_products_name', $this->transaction_detail_products_name, true);
        $criteria->compare('transaction_detail_quantity', $this->transaction_detail_quantity, true);
        $criteria->compare('transaction_detail_price', $this->transaction_detail_price, true);
        $criteria->compare('transaction_detail_bv', $this->transaction_detail_bv, true);

        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

}